<template>
  <h2>我是About的内容</h2>
</template>

<script>
export default {
  name: "About",
  mounted() {
    console.log("About组件被挂载了");
    window.aboutRoute = this.$route;
    window.aboutRouter = this.$router;
  },
  beforeDestroy() {
    console.log("About组件即将被销毁了");
  },
  //通过路由规则，进入该组件时被调用
  beforeRouteEnter(to, from, next) {
    console.log("About-beforeRouteEnter", to, from);
    if (to.meta.isAuth) {
      if (localStorage.getItem("school") === "jian") {
        next();
      } else {
        alert("此学校没有权限查看");
      }
    } else {
      next();
    }
  },
  //通过路由规则，离开该组件时被调用
  beforeRouteLeave(to, from, next) {
    console.log("About-beforeRouteLeave", to, from);
    next();
  },
};
</script>

<style>
</style>